#include <iostream>
#include <string.h>
using namespace std;

/*
    类的大小：跟成员变量（成员属性）有关，跟成员方法无关，也满足字节对齐（规则跟结构体一模一样）
            空类的大小是1字节

*/

class Cat
{
public:
    // void catchMouse();
    // void playMagic();
    void setAttr(int a, char *n, float w);
    void show();
    void size()
    {
        cout << "sizeof(Cat) = " << sizeof(Cat) << endl;
    }
private:
    int age;
    char name[32];
    float weight;
};

// void Cat::catchMouse()
// {
//     cout << "抓老鼠" << endl;
// }
// void Cat::playMagic()
// {
//     cout << "玩魔方" << endl;
// }
void Cat::setAttr(int a, char *n, float w)
{
    age = a;
    strcpy(name, n);
    weight = w;
}
void Cat::show()
{
    cout << "年龄：" << age << endl;
    cout << "名字：" << name << endl;
    cout << "体重：" << weight << endl;
}
int main()
{
    Cat c1;
    c1.size();
    char name[32] = "Tom";
    c1.setAttr(3, name, 5.5);
    c1.show();
    // c1.catchMouse();


    return 0;
}